home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_gene.lha / LEDA-3.1c-generic / incl / LEDA / window.h < prev   
Encoding:
C/C++ Source or Header  |  1994-08-05  |  9.5 KB  |  335 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  3.1c
  4. +
  5. +
  6. +  window.h
  7. +
  8. +
  9. +  Copyright (c) 1994  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15. #ifndef LEDA_WINDOW_H
  16. #define LEDA_WINDOW_H
  17.  
  18. #include <LEDA/basic.h>
  19. #include <LEDA/plane.h>
  20. #include <LEDA/leda_window.h>
  21. #include <LEDA/leda_panel.h>
  22.  
  23.  
  24. class window : public LEDA_WINDOW {
  25.  
  26. public:
  27.  
  28. enum placement {min = -1, center =-2, max = -3 };
  29.  
  30.  window(float width, float height, float xpos, float ypos, 
  31.         const char* = LEDA::version_string);
  32.  
  33.  window(float width, float height,const char* = LEDA::version_string);
  34.  
  35.  window(const char* = LEDA::version_string);
  36.  
  37.  window(int);  // just create, do not open
  38.  
  39.  window(const window& w) : LEDA_WINDOW(w) {}
  40.  
  41.  window& operator=(const window& w) 
  42.  { LEDA_WINDOW::operator=(w); return *this; }
  43.  
  44. ~window() {}   // ~LEDA_WINDOW does this job
  45.  
  46.  
  47. operator void*() { return (state==0) ? 0 : this; }
  48.  
  49. // pixels
  50.  
  51. void draw_pix(double x, double y, color c=FG_color );
  52. void draw_pix(const point& p, color c=FG_color );
  53.  
  54.  
  55. // points
  56.  
  57. void draw_point(double x0,double y0,color c=FG_color);
  58. void draw_point(const point& p,color c=FG_color);
  59.  
  60.  
  61. // nodes
  62.  
  63. void draw_node(double x0,double y0,color c=FG_color);
  64. void draw_node(const point& p, color c=FG_color);
  65. void draw_filled_node(double x0,double y0,color c=FG_color);
  66. void draw_filled_node(const point& p, color c=FG_color);
  67. void draw_text_node(double x,double y,string s,color c=BG_color);
  68. void draw_text_node(const point& p ,string s,color c=BG_color);
  69. void draw_int_node(double x,double y,int i,color c=BG_color);
  70. void draw_int_node(const point& p ,int i,color c=BG_color);
  71.  
  72.  
  73. // drawing segments
  74.  
  75. void draw_segment(double x1, double y1, double x2, double y2, color c=FG_color );
  76. void draw_segment(const point& p, const point& q, color c=FG_color );
  77. void draw_segment(const segment& s, color c=FG_color );
  78.  
  79.  
  80. // drawing arcs
  81.  
  82. void draw_arc(double,double,double,double,double,color=FG_color);
  83. void draw_arc(const point&,const point&,double,color=FG_color);
  84. void draw_arc(const segment&,double,color=FG_color);
  85.  
  86.  
  87. // arrows
  88.  
  89. point draw_arrow_head(const point& q, double dir, color c=FG_color);
  90.  
  91. void draw_arrow(double, double, double, double, color=FG_color );
  92. void draw_arrow(const point&, const point&, color=FG_color );
  93. void draw_arrow(const segment&, color=FG_color );
  94.  
  95. void draw_arc_arrow(double,double,double,double,double,color=FG_color);
  96. void draw_arc_arrow(const point&,const point&,double,color=FG_color);
  97. void draw_arc_arrow(const segment&,double,color=FG_color);
  98.  
  99.  
  100. // edges
  101.  
  102. void draw_edge(double,double,double,double, color c=FG_color);
  103. void draw_edge(const point&, const point&, color=FG_color );
  104. void draw_edge(const segment&, color=FG_color );
  105.  
  106. void draw_edge_arrow(double,double,double,double, color c=FG_color);
  107. void draw_edge_arrow(const point&, const point&, color=FG_color );
  108. void draw_edge_arrow(const segment&, color=FG_color );
  109.  
  110. void draw_arc_edge(double,double,double,double, color c=FG_color);
  111. void draw_arc_edge(const point&, const point&, double, color=FG_color );
  112. void draw_arc_edge(const segment&, double, color=FG_color );
  113.  
  114. void draw_arc_edge_arrow(double,double,double,double, color c=FG_color);
  115. void draw_arc_edge_arrow(const point&, const point&, double, color=FG_color );
  116. void draw_arc_edge_arrow(const segment&, double, color=FG_color );
  117.  
  118.  
  119.  
  120. // lines
  121.  
  122. void draw_hline(double y, color c=FG_color );
  123. void draw_vline(double x, color c=FG_color );
  124. void draw_line(double x1, double y1, double x2, double y2, color c=FG_color );
  125. void draw_line(const point& p, const point& q, color c=FG_color);
  126. void draw_line(const segment& s, color c=FG_color);
  127. void draw_line(const line& l, color c=FG_color);
  128.  
  129.  
  130.  
  131. //circles
  132.  
  133. void draw_circle(double x,double y,double r,color c=FG_color);
  134. void draw_circle(const point& p,double r,color c=FG_color);
  135. void draw_circle(const circle& C,color c=FG_color);
  136.  
  137. void draw_disc(double x,double y,double r,color c=FG_color);
  138. void draw_disc(const point& p,double r,color c=FG_color);
  139. void draw_disc(const circle& C,color c=FG_color);
  140.  
  141.  
  142. //ellipses
  143.  
  144. void draw_ellipse(double x,double y,double r1, double r2, color c=FG_color);
  145. void draw_ellipse(const point& p, double r1, double r2, color c=FG_color);
  146.  
  147. void draw_filled_ellipse(double x,double y,double r1, double r2, color c=FG_color);
  148. void draw_filled_ellipse(const point& p, double r1, double r2, color c=FG_color);
  149.  
  150.  
  151. //polygons 
  152.  
  153. void draw_polygon(const list<point>& lp, color c=FG_color );
  154. void draw_polygon(const polygon& P, color c=FG_color );
  155.  
  156. void draw_filled_polygon(const list<point>& lp, color c=FG_color );
  157. void draw_filled_polygon(const polygon& P,color c=FG_color );
  158.  
  159. void draw_rectangle(double a, double  b, double c, double d, color=FG_color);
  160. void draw_filled_rectangle(double a, double  b, double c, double d, color=FG_color);
  161.  
  162.  
  163. // text
  164.  
  165. void draw_text(double x, double y, string s, color c=FG_color);
  166. void draw_text(const point& p, string s, color c=FG_color);
  167. void draw_ctext(double x, double y, string s, color c=FG_color);
  168. void draw_ctext(const point& p, string s, color c=FG_color);
  169.  
  170.  
  171. // functions
  172.  
  173. void plot_xy(double x0, double x1, draw_func_ptr f, color c=FG_color);
  174. void plot_yx(double y0, double y1, draw_func_ptr f, color c=FG_color);
  175.  
  176.  
  177.  
  178. // miscellaneous
  179.  
  180. void clear(color c=BG_color) { LEDA_WINDOW::clear(c); };
  181.  
  182. void del_message() { LEDA_WINDOW::del_messages(); };
  183.  
  184. void fill(double x, double y, color c=FG_color);
  185.  
  186. void copy_rect(double x1, double y1, double x2, double y2, double x, double y);
  187. void move_rect(double x1, double y1, double x2, double y2, double x, double y);
  188. void copy(double x1, double y1, double x2, double y2, int i=0);
  189. void cut(double x1, double y1, double x2, double y2, int i=0);
  190. void paste(int i, double x, double y);
  191. void paste(double x, double y);
  192. void clear_buf(int i=0);
  193.  
  194.  
  195. // mouse input
  196.  
  197. /*
  198. friend int read_mouse(window*& w, double& x, double& y);
  199. */
  200.  
  201. int get_button();
  202. int get_button(double&, double&);
  203. int get_button(point&);
  204.  
  205. int read_mouse();
  206. int read_mouse(double&, double&);
  207. int read_mouse(point&);
  208.  
  209. int read_mouse_seg(double, double, double&, double&);
  210. int read_mouse_seg(const point&, point&);
  211.  
  212. int read_mouse_rect(double, double, double&, double&);
  213. int read_mouse_rect(const point&, point&);
  214.  
  215. int read_mouse_circle(double, double, double&, double&);
  216. int read_mouse_circle(const point&, point&);
  217.  
  218. int read_mouse_action(mouse_action_func_ptr, double&, double&);
  219. int read_mouse_action(mouse_action_func_ptr, point&);
  220.  
  221.  
  222. // panel input
  223.  
  224. int     confirm(string s);
  225. void    acknowledge(string s);
  226. void    notice(string s);
  227.  
  228. int     read_panel(string, int, string*);
  229. int     read_vpanel(string, int, string*);
  230.  
  231. string  read_string(string);
  232. double  read_real(string);
  233. int     read_int(string);
  234.  
  235. // I/O operators
  236.  
  237. window& read(point&);
  238. window& read(segment&);
  239. window& read(line&);
  240. window& read(circle&);
  241. window& read(polygon&);
  242.  
  243. window& operator>>(point&);
  244. window& operator>>(segment&);
  245. window& operator>>(line&);
  246. window& operator>>(circle&);
  247. window& operator>>(polygon&);
  248.  
  249. window& draw(const point& p,color c=FG_color)   { draw_point(p,c); return *this;  }
  250. window& draw(const segment& s,color c=FG_color) { draw_segment(s,c); return *this;}
  251. window& draw(const line& l,color c=FG_color)    { draw_line(l,c); return *this;   }
  252. window& draw(const circle& C,color c=FG_color)  { draw_circle(C,c); return *this; }
  253. window& draw(const polygon& P,color c=FG_color ){ draw_polygon(P,c); return *this;}
  254.  
  255. window& operator<<(const point& p)   { return draw(p); }
  256. window& operator<<(const segment& s) { return draw(s); }
  257. window& operator<<(const line& l)    { return draw(l); }
  258. window& operator<<(const circle& C)  { return draw(C); }
  259. window& operator<<(const polygon& P) { return draw(P); }
  260.  
  261.  
  262.  
  263. }; // end of class window
  264.   
  265.  
  266.  
  267. //------------------------------------------------------------------------------
  268. //   PANELS
  269. //------------------------------------------------------------------------------
  270.  
  271. class panel : public LEDA_PANEL {
  272.  
  273. public:
  274.  
  275.  panel() {}
  276.  panel(string s) : LEDA_PANEL(s) {}
  277. ~panel() {}
  278.  
  279.  
  280. void label(string s);
  281. void text_item(string s);
  282.  
  283. void string_item(string s, string& x);
  284. void string_item(string label,string& x,list<string>& L);
  285.  
  286. void choice_item(string header,int& x,list<string>& L);
  287. void choice_item(string header,int& x,string,string);
  288. void choice_item(string header,int& x,string,string,string);
  289. void choice_item(string header,int& x,string,string,string,string);
  290. void choice_item(string header,int& x,string,string,string,string,string);
  291.  
  292. void int_item(string s,int& x);
  293. void int_item(string s,int& x, int l, int h, int step);
  294. void int_item(string s,int& x, int l, int h);
  295.  
  296. void bool_item(string s, bool& x);
  297. void real_item(string s, double& x);
  298. void double_item(string s, double& x);
  299.  
  300. void color_item(string s, color& x);
  301. void lstyle_item(string s, line_style& x);
  302.  
  303. int button(string s);
  304.  
  305. void new_button_line();
  306. void new_button_line(list<string>&);
  307.  
  308.  
  309. // display panel window on screen
  310.  
  311. void display();                       // center on screen
  312. void display(int x,int y);            // at (x,y) on screen
  313. void display(window& W);              // center on window W
  314. void display(window& W, int x,int y); // at (x,y) on window W
  315.  
  316.  
  317. // read panel
  318.  
  319. int  read() { return LEDA_PANEL::read(); }
  320.  
  321.  
  322. // open = display + read
  323.  
  324. int  open();                       // center on screen
  325. int  open(int x,int y);            // at (x,y) on screen
  326. int  open(window& W);              // center on window W
  327. int  open(window& W, int x,int y); // at (x,y) on window W
  328.  
  329. int  open(list<string> buttons)   { new_button_line(buttons); return open(); }
  330.  
  331. };
  332.  
  333. #endif
  334.